Skip to content

Introduce new extended attribute grammars #1503

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 30, 2025

Conversation

lukewarlow
Copy link
Member

@lukewarlow lukewarlow commented Jul 14, 2025

Introduce four new extended attribute grammars

These new grammars will be used by the HTML spec for attribute reflection extended attributes. ExtendedAttributeString ([Reflect="foo"]), ExtendedAttributeInteger ([ReflectDefault=1]), ExtendedAttributeDecimal ([ReflectDefault=1.0]) and ExtendedAttributeIntegerList ([ReflectRange=(1,100)]) are added.

(See WHATWG Working Mode: Changes for more details.)


Preview | Diff

These new grammars will be used by the HTML spec for attribute reflection extended attributes.
Copy link
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good with nit, although I presume we shouldn't merge this until we're sure they're going to be used.

@lukewarlow
Copy link
Member Author

I presume we shouldn't merge this until we're sure they're going to be used.

Yeah I think it makes sense to wait until at least the non-enum IDL reflection stuff is agreed upon. That uses all 3 of these new grammars.

@lukewarlow lukewarlow marked this pull request as ready for review July 17, 2025 11:54
@lukewarlow lukewarlow changed the title Introduce three new extended attribute grammars Introduce new extended attribute grammars Jul 17, 2025
@lukewarlow
Copy link
Member Author

I think this is ready to go now. The python parser has been updated which I think is the main blocker. It seems the HTML PR is ready to go so these new grammars will end up being used.

@domenic domenic merged commit ef2df44 into whatwg:main Jul 30, 2025
2 checks passed
annevk pushed a commit to whatwg/html that referenced this pull request Jul 30, 2025
A number of extended attributes are added which trigger IDL attribute reflection:

- [Reflect] and [Reflect=string] cover basic content attribute reflection cases.
- [ReflectSetter] and [ReflectSetter=string] covers content attribute reflection only for setters.
- [ReflectURL] and [ReflectURL=string] covers reflection of USV attributes, which represent URLs.
- [ReflectNonNegative] and [ReflectNonNegative=string] covers reflection of long attributes that should be limited to only non-negative numbers.
- [ReflectPositive] and [ReflectPositive=string] covers reflection of double and unsigned long attributes which should be limited to positive numbers.
- [ReflectPositiveWithFallback] and [ReflectPositiveWithFallback=string] covers reflection of double and unsigned long attributes which should be limited to positive numbers with fallback.

Additionally:

- [ReflectRange=(integer, integer)] can be used alongside others on unsigned long attributes that should be clamped to a range.
- [ReflectDefault=number] can be used alongside others on double, long and unsigned long attributes that should be reflected with a default value.

Corresponding Web IDL PR: whatwg/webidl#1503.
@lukewarlow lukewarlow deleted the reflect-idl-syntax branch July 30, 2025 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants